package com.game.module.gameTask.view
{
	import com.dusk.game.Logger;
	import com.dusk.util.ResUtil;
	import com.dusk.util.TextUtil;
	import com.game.view.component.ComponentBase;
	
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	public class AwardItem extends ComponentBase
	{
		
		public function AwardItem()
		{
			super();
		}
		
		public var itemName:TextField;
		private var img:Bitmap;
		
		override protected function beforeAdded():void
		{
			var mc:MovieClip = ResUtil.getComponentView("AwardItem") as MovieClip;
			TextUtil.redrawTxt(mc);
			itemName = mc.getChildByName("itemName") as TextField;
			addChild(mc);
		}
		
		public function addImage(param1:String):void
		{
			var bName:String = param1;
			try
			{
				this.img = ResUtil.getImageBitmap(bName);
				this.img.name = bName;
				this.img.x = 3.5;
				this.img.y = 3.5;
				this.addChild(this.img);
			} catch (e:Error)
			{
				Logger.logError("找不到图片: " + bName,this);
			}
		}
		
		public function removeImage():void
		{
			if (Boolean(this.img) && contains(this.img))
			{
				this.removeChild(this.img);
				this.itemName.text = "";
			}
		}
		
		override protected function onRemoved():void
		{
			removeImage();
		}
	}
}
